﻿using _05.建构者模式.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _05.建构者模式.Builders
{
    /// <summary>
    /// 指挥官 或 导演 ，作用是指挥 Builder 去建构具体的手机
    /// </summary>
    public class Director
    {
        private Builder Builder;
        private IBuilder builder;

        public Director(IBuilder builder)
        {
            this.builder = builder;
        }

        public Director(Builder builder)
        {
            this.Builder = builder;
        }

        public IPhone DoWork(IBuilder _builder = null)
        {
            if (_builder != null)
            {
                this.builder = _builder;
            }

            builder.BuildBattery();
            builder.BuildCamera();
            builder.BuildCPU();
            builder.BuildMemory();
            builder.BuildScreen();

            return builder.GetPhone();

        }


        public IPhone DoBuild(Builder _builder = null)
        {
            if (_builder != null)
            {
                this.Builder = _builder;
            }

            Builder.BuildBattery();
            Builder.BuildCamera();
            Builder.BuildCPU();
            Builder.BuildMemory();
            Builder.BuildScreen();

            return Builder.GetPhone();

        }
    }
}
